ser.loc[]
ser.loc[label]
Returns the element of the Series that corresponds to its row label.
- Note:
- Often
ser
comes fromdf.get(column_name)
. - In DSC 10, we only use
loc
andiloc
on Series, and never on DataFrames. That's because we want to avoid working with row objects, which contain data of varying types. To extract something from a data frame, you should always useget
first to grab the column as a series, then useloc
oriloc
to get the individual entry.
species_ser
- dog_001"dog"
- cat_001"cat"
- cat_002"cat"
- dog_002"dog"
- dog_003"dog"
- ham_001"hamster"
- ham_002"hamster"
- cat_003"cat"
species_ser.loc['dog_002']
'dog'
Problems or suggestions about this page? Fill out our feedback form.